﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bank
{
    //存款接口
    interface ISave
    {
        void saveMoney(int quan);
    }

    //取款接口
    interface IWithdraw
    {
        bool withdrawMoney(int quan);
    }

    //账户类，实现ISave、IWithdraw接口
    public class Account:ISave, IWithdraw
    {
        private int id;   //账户号
        private int password;   //密码
        private int money;   //余额

        //Money属性
        public int Money
        {
            get
            {
                return money;
            }
            set
            {
                money = value;
            }
        }

        public Account(int ID, int mon, int pwd)
        {
            id = ID;
            Money = mon;
            password = pwd;
        }

        public int getId()
        {
            return id;
        }

        public int getMoney()
        {
            return Money;
        }

        public int getPwd()
        {
            return password;
        }

        //存款方法
        public virtual void saveMoney(int quan)
        {
            Money += quan;
        }

        //取款方法
        public virtual bool withdrawMoney(int quan)
        {
            if (money >= quan)
            {
                Money -= quan;
                return true;
            }
            else
                return false;
        }

        public void setPwd(int newPwd)
        {
            password = newPwd;
        }

        public void setId(int ID)
        {
            id = ID;
        }

        public void setMoney(int mon)
        {
            Money = mon;
        }
    }
}
